//
//  ZYCTeaLeaveRecordDetailHeaderView.m
//  ZDSC
//
//  Created by 张威 on 2021/10/21.
//

#import "ZYCTeaLeaveRecordDetailHeaderView.h"
#import "ZYCTeaLeaveRecordRootModel.h"

@interface ZYCTeaLeaveRecordDetailHeaderView ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *statusLabel;
@property (nonatomic, strong) UILabel *dateLabel;
@end
@implementation ZYCTeaLeaveRecordDetailHeaderView

- (void)setModel:(ZYCTeaLeaveRecordRootModel *)model{
    _model = model;
    _titleLabel.text = model.leaveTitle;
    if ([model.status integerValue] == 1) {
        _statusLabel.textColor = HEX_RGB(@"#EEA92D");
    }else if([model.status integerValue] == 2){
        _statusLabel.textColor = HEX_RGB(@"#E93C06");
    }else if([model.status integerValue] == 3){
        _statusLabel.textColor = HEX_RGB(@"#41B166");
    }else{
        _statusLabel.textColor = HEX_RGB(@"#999999");
    }
    _statusLabel.text = model.statusStr;

    _dateLabel.text = model.createTime;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = HEX_RGB(@"FFFFFF");
        [self addSubview:self.bgView];
        [self addSubview:self.titleLabel];
        [self addSubview:self.statusLabel];
        [self addSubview:self.dateLabel];
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(self);
            make.height.mas_equalTo(10.0f);
        }];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(15.0f);
            make.top.equalTo(self.bgView.mas_bottom).offset(10.0f);
        }];
        
        [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-15.0f);
            make.centerY.equalTo(self.titleLabel);
        }];
        
        [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(15.0f);
            make.top.equalTo(self.titleLabel.mas_bottom).offset(8.5f);
        }];
    }
    return self;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Medium", 22.0f) titleColor:HEX_RGB(@"#333333") textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}

- (UILabel *)statusLabel {
    if (!_statusLabel) {
        _statusLabel = [[UILabel alloc] init];
        _statusLabel.font = kCustomFont(@"PingFangSC-Medium", 17.0f);
    }
    return _statusLabel;
}

- (UILabel *)dateLabel {
    if (!_dateLabel) {
        _dateLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 14.0f) titleColor:HEX_RGB(@"#999999") textAlignment:ZZTextAlignmentLeft];
    }
    return _dateLabel;
}

- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = HEX_RGB(@"#FAFAFA");
    }
    return _bgView;
}

@end
